package cycling.taxi.com.person;

import android.app.ProgressDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.ButterKnife;
import butterknife.InjectView;
import cycling.taxi.com.R;
import cycling.taxi.com.entity.Repair;
import cycling.taxi.com.utils.SPUtil;
import cycling.taxi.com.utils.ToastUtil;
import cycling.taxi.com.utils.Urls;

/**
 * 意见反馈界面
 */
public class FedbackActivity extends AppCompatActivity implements View.OnClickListener{
    private ImageView back;
    private EditText suggest;
    private Button btnfeedback;
    private RequestQueue queue;
    private String content;
    private String beanJson;
    private String status;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fedback);
        ExitApplication.getInstance().addActivity(this);
        back=(ImageView)findViewById(R.id.back);
        suggest=(EditText) findViewById(R.id.suggest);
        btnfeedback=(Button)findViewById(R.id.btnfeedback);
        back.setOnClickListener(this);
        btnfeedback.setOnClickListener(this);
        queue= Volley.newRequestQueue(this);

    }


    @Override
    public void onClick(View v) {
        if(v.getId()==R.id.btnfeedback){
            volleyPost();
        }
        if (v.getId() ==R.id.back){

            finish();
        }

    }
    public void volleyPost(){
      //  String path= "http://192.168.1.100:8080/CyclingBgTV1/appFeedback/feedback.dop";
        String path = Urls.getFeedBack();
        StringRequest request = new StringRequest(Request.Method.POST,path, new Response.Listener<String>() {
            @Override
            public void onResponse(String s) {
                status=s;
                if(status.equals("1"))
                 ToastUtil.getInstance().toast("提交成功");
            }
        },null){
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String,String > map= new HashMap<String,String>();
                String beanJson=SPUtil.getInstance().getData("beanJson");
                content=suggest.getText().toString();
                map.put("content",content);
                map.put("beanJson",beanJson);
                return map;
            }
        };
        queue.add(request);
    }

}
